import * as echarts from "echarts";

export const getCondoleOptions = () => {
  return {
    title: {
      top: 15,
      left: 10,
      textStyle: {
        fontSize: 16,
        color: "#fff",
      },
      text: "本年度职工慰问情况",
    },
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },
    legend: {
      right: 10,
      top: 15,
      textStyle: {
        fontSize: 13,
        color: "#2F89CF",
      },
      data: [
        { name: "人数", itemStyle: { color: "rgb(135, 208, 104,1)" } },
        { name: "金额", itemStyle: { color: "rgba(95, 187, 235, 1)" } },
      ],
    },
    grid: {
      top: "25%",
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true,
    },
    xAxis: [
      {
        type: "category",
        data: [
          "生日",
          "生育",
          "婚庆",
          "退休",
          "住院",
          "丧事",
          "工伤",
          "节日",
          "劳模",
          "助学",
        ],
      },
    ],
    yAxis: [
      {
        type: "value",
        name: "人数",
        axisLabel: {
          padding: [3, 0, 0, 0],
          formatter: "{value}",
          color: "rgb(135, 208, 104,1)",
          textStyle: {
            fontSize: 11,
          },
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: "rgb(135, 208, 104,0)",
          },
        },
      },
      {
        type: "value",
        name: "金额",
        axisLabel: {
          padding: [3, 0, 0, 0],
          formatter: "{value}",
          color: "rgba(95, 187, 235, 1)",
          textStyle: {
            fontSize: 11,
          },
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: "rgb(135, 208, 104,0)",
          },
        },
      },
    ],
    series: [
      {
        name: "人数",
        type: "bar",
        data:
          [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]?.map(() =>
            Math.floor(Math.random() * 100)
          ) || [],
        tooltip: {
          valueFormatter: function (value: string | number) {
            return value + " 个";
          },
        },

        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0,
              0,
              0,
              1,
              [
                {
                  offset: 0,
                  color: "rgb(135, 208, 104,1)", // 0% 处的颜色
                },
                {
                  offset: 0.98,
                  color: "rgba(5, 213, 255, 0)", // 100% 处的颜色
                },
              ],
              false
            ),
            // rgba(5, 213, 255, 1)
            shadowColor: "rgb(135, 208, 104,1)",
            shadowBlur: 4,
          },
        },
      },
      {
        name: "金额",
        type: "bar",
        data:
          [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]?.map(() =>
            Math.floor(Math.random() * 10000)
          ) || [],
        yAxisIndex: 1,
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0,
              0,
              0,
              1,
              [
                {
                  offset: 0,
                  color: "rgba(5, 213, 255, 1)", // 0% 处的颜色
                },
                {
                  offset: 0.98,
                  color: "rgba(5, 213, 255, 0)", // 100% 处的颜色
                },
              ],
              false
            ),
            shadowColor: "rgba(5, 213, 255, 1)",
            shadowBlur: 4,
          },
        },
        tooltip: {
          valueFormatter: function (value: string | number) {
            return value + " 元";
          },
        },
      },
    ],
  };
};
